package online.sixfish.doubao.controller;

import online.sixfish.common.api.ApiResult;
import online.sixfish.doubao.model.entity.Notice;
import online.sixfish.doubao.service.NoticeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/notice")
public class NoticeController {
    @Resource
    NoticeService noticeService;

    /**
     * 获取最近公告
     * @return {@code ApiResult}
     */
    @GetMapping("/recent")
    public ApiResult getRecentNotice(){
        List<Notice> notices = noticeService.getRecentNotice();
        return ApiResult.success(notices);
    }

    @GetMapping("/detail/{id}")
    public ApiResult getById(@PathVariable Integer id){
        Notice notice = noticeService.getById(id);
        return ApiResult.success(notice);
    }

}
